package com.principle.singleton.type1;

public class SingletonTest01 {
    public static void main(String[] args) {
        //测试
        System.out.println("枚举");
        Singleton instance = Singleton.INSTANCE;
        Singleton instance1 = Singleton.INSTANCE;
        System.out.println(instance==instance1);//true
        System.out.println(instance.hashCode());
        System.out.println(instance1.hashCode());
        instance.sayOk();
        instance1.sayOk();
    }
}
//静态内部类，推荐使用
enum Singleton{
    INSTANCE;//属性
    public void sayOk(){
        System.out.println("OK---");
    }
}